package com.smcdd.cdb.dbo.cdb_dbo.network;


import java.io.IOException;

import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Jeremylee on 2017/6/5.
 */

public class AuthInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {

        Request origin = chain.request();

        Headers originHeads = origin.headers();

        Headers.Builder newHeaders = new Headers.Builder();
        newHeaders.add("Content-Type", "application/json;charset=UTF-8");

        for (int i = 0; i < originHeads.size(); i++) {

            newHeaders.add(originHeads.name(i), originHeads.value(i));
        }
        Request.Builder newRequest = origin.newBuilder().headers(newHeaders.build());
        return chain.proceed(newRequest.build());
    }
}
